Skip to content

refactor: codebase simplification across 6 phases#106

Merged
shrimalmadhur merged 4 commits intomainfrom
issue/can-you-run-code-simplifier-plugin-or-ag-9a46e3e3
Mar 28, 2026
Merged

refactor: codebase simplification across 6 phases#106
shrimalmadhur merged 4 commits intomainfrom
issue/can-you-run-code-simplifier-plugin-or-ag-9a46e3e3

Conversation

@shrimalmadhur
Copy link
Copy Markdown
Owner

Summary

Comprehensive codebase cleanup and simplification across 6 phases:

  • Phase 1: Remove unused exports (SLACK_MAX_MSG_LEN, escapeSlackText, AgentConfig)
  • Phase 2: Deduplicate shared constants (inputClasses, formatTokens, DENIED_ENV_KEYS)
  • Phase 3: Merge duplicate timeline builders, extract metadata helper in claude module
  • Phase 4: Extract notification upsert helper with ON CONFLICT, add MCP PATCH validation
  • Phase 5: Decompose 990-line settings page into 3 self-contained section components
  • Phase 6: Split 1,536-line pipeline.ts into 4 modules (prompts, claude-runner, helpers, orchestrator)

Key metrics

  • Settings page: 990 → 35 lines (sections extracted to components/settings/)
  • Pipeline: 1,536 → 2 lines re-export (logic split into pipeline/ subdirectory)
  • Timeline builders: merged buildTimeline + buildSubAgentTimeline into one parameterized function
  • Notification upserts: 5 inline select-then-branch patterns → shared ON CONFLICT helper
  • New Drizzle migration: unique constraint on notification_configs.channel
  • New tests: formatTokens utility, timeline builder regression tests

Test plan

  • Verify bun run tsc --noEmit passes
  • Verify settings page renders correctly with all 3 sections
  • Verify issue pipeline still processes Slack and Telegram ingress
  • Verify MCP server CRUD operations work
  • Verify notification/telegram config operations work
  • Run new tests: bun test build-timeline and bun test format

Issue: can you run code simplifier plugin or agent to clean up whole codebase

🤖 Generated with Claude Code

shrimalmadhur and others added 2 commits March 27, 2026 16:40
Phase 1: Remove unused exports (SLACK_MAX_MSG_LEN, escapeSlackText, AgentConfig)
Phase 2: Deduplicate shared constants (inputClasses, formatTokens, DENIED_ENV_KEYS)
Phase 3: Merge duplicate timeline builders, extract metadata helper in claude module
Phase 4: Extract notification upsert helper with ON CONFLICT, add MCP PATCH validation
Phase 5: Decompose 990-line settings page into 3 self-contained section components
Phase 6: Split 1,536-line pipeline.ts into 4 modules (prompts, claude-runner, helpers, orchestrator)

- Settings page: 990 → 35 lines (sections extracted to components/settings/)
- Pipeline: 1,536 → 2 lines re-export (logic split into pipeline/ subdirectory)
- Timeline builders: merged buildTimeline + buildSubAgentTimeline into one parameterized function
- Notification upserts: 5 inline select-then-branch patterns → shared ON CONFLICT helper
- New Drizzle migration: unique constraint on notification_configs.channel
- New tests: formatTokens utility, timeline builder regression tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The unique constraint on notification_configs.channel and the associated
Drizzle migration are out of scope for a pure code simplification task.
Rewrote the notification-config helper to use select-then-update/insert
instead of ON CONFLICT, so no schema change is needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@shrimalmadhur shrimalmadhur force-pushed the issue/can-you-run-code-simplifier-plugin-or-ag-9a46e3e3 branch from 0a25619 to a30e9b2 Compare March 27, 2026 23:41
shrimalmadhur and others added 2 commits March 28, 2026 16:06
…components

- Extract shared `parseBody` helper for Zod validation (replaces 9 identical
  safeParse+error blocks across API routes)
- Deduplicate claude session module: move `summarizeToolInput` and
  `extractMetadata` to shared session-utils, reuse `aggregateTokensFromEntries`
  in session-reader instead of reimplementing token aggregation
- Extract `removeWorktree`/`forceRemoveWorktree`/`pruneWorktrees` helpers
  (replaces 4 duplicated git worktree cleanup blocks)
- Consolidate `settingsInputClasses` into shared form-classes.ts (3 components)
- Move inline MCP server update schema to src/lib/validations/mcp.ts
- Remove unused API helpers (jsonResponse, notFound, conflict, badRequest)
  and replace tests with parseBody coverage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix extractSessionMetadata direction: reverse entries in session-reader
  to preserve "most recent values" behavior from the old backward walk
- Restore aggregateTokensFromFile fast-path: use string pre-checks to
  skip JSON parsing for lines without usage data (perf hot path)
- Extract duplicated SlackIcon/TelegramIcon SVGs to shared source-icons
  component (was copy-pasted in issues/page.tsx and issues/[id]/page.tsx)
- Return config id from upsertNotificationConfig and telegram POST
  response to maintain API backward compatibility

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@shrimalmadhur shrimalmadhur merged commit 5b0d7b8 into main Mar 28, 2026
3 checks passed
@shrimalmadhur shrimalmadhur deleted the issue/can-you-run-code-simplifier-plugin-or-ag-9a46e3e3 branch March 28, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant